﻿// Calib_IntrinPara_Dlg.cpp: 实现文件
//

#include "pch.h"
#include "SakerProject.h"
#include "Calib_IntrinPara_Dlg.h"
#include "afxdialogex.h"

#include "xxFileProcess.h"
#include "mmFile_Paras.h"
#include "xxWidgetControl.h"

#include "CurProject.h"


// CCalib_IntrinPara_Dlg 对话框
CCalib_IntrinPara_Dlg * m_Calib_IntrinPara;

IMPLEMENT_DYNAMIC(CCalib_IntrinPara_Dlg, CDialogEx)

CCalib_IntrinPara_Dlg::CCalib_IntrinPara_Dlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_Calib_IntrinPara, pParent)
{

}

CCalib_IntrinPara_Dlg::~CCalib_IntrinPara_Dlg()
{
}

void CCalib_IntrinPara_Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CCalib_IntrinPara_Dlg, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON_Save, &CCalib_IntrinPara_Dlg::OnBnClickedButtonSave)
END_MESSAGE_MAP()


// CCalib_IntrinPara_Dlg 消息处理程序


BOOL CCalib_IntrinPara_Dlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	mmCalib.SelCalibModel = xx::InitCB(this, IDC_COMBO_CalibModel, mmCalib.vecCalibModelNames, mmCalib.iniField, L"CalibModel", mmFile_Paras.iniModelPath(), 0);
	mmCalib.IntrinPara.u0Spec = xx::InitWidget(this, IDC_EDIT_u0Spec, mmCalib.iniField, L"u0Spec", mmFile_Paras.iniModelPath(), 0.0);
	mmCalib.IntrinPara.v0Spec = xx::InitWidget(this, IDC_EDIT_v0Spec, mmCalib.iniField, L"v0Spec", mmFile_Paras.iniModelPath(), 0.0);
	mmCalib.IntrinPara.ReproSpec = xx::InitWidget(this, IDC_EDIT_ReproSpec, mmCalib.iniField, L"ReproSpec", mmFile_Paras.iniModelPath(), 0.0);

	xx::WriteWidget(this, IDC_EDIT_u0Length, mmCalib.IntrinPara.u0Length);
	xx::WriteWidget(this, IDC_EDIT_v0Length, mmCalib.IntrinPara.v0Length);

	xx::WriteWidget(this, IDC_EDIT_FOV, CurProject.FOV);
	xx::WriteCK(this, IDC_CHECK_RationalModel, mmCalib.Flag_RationalModel);

	return TRUE;
}


void CCalib_IntrinPara_Dlg::OnBnClickedButtonSave()
{
	mmCalib.SelCalibModel = xx::DefaultCB(this, IDC_COMBO_CalibModel, mmCalib.iniField, L"CalibModel", mmFile_Paras.iniModelPath(), 0);
	mmCalib.IntrinPara.u0Spec = xx::DefaultWidget(this, IDC_EDIT_u0Spec, mmCalib.iniField, L"u0Spec", mmFile_Paras.iniModelPath(), 0.0);
	mmCalib.IntrinPara.v0Spec = xx::DefaultWidget(this, IDC_EDIT_v0Spec, mmCalib.iniField, L"v0Spec", mmFile_Paras.iniModelPath(), 0.0);
	mmCalib.IntrinPara.ReproSpec = xx::DefaultWidget(this, IDC_EDIT_ReproSpec, mmCalib.iniField, L"ReproSpec", mmFile_Paras.iniModelPath(), 0.0);
	mmCalib.IntrinPara.u0Length = xx::DefaultWidget(this, IDC_EDIT_u0Length, mmCalib.iniField, L"u0Length", mmFile_Paras.iniModelPath(), 0.0);
	mmCalib.IntrinPara.v0Length = xx::DefaultWidget(this, IDC_EDIT_v0Length, mmCalib.iniField, L"v0Length", mmFile_Paras.iniModelPath(), 0.0);
	
	CurProject.FOV = xx::DefaultWidget(this, IDC_EDIT_FOV, CurProject.iniField, L"FOV", mmFile_Paras.iniModelPath(), 0);

	mmCalib.Flag_RationalModel = xx::DefaultCK(this, IDC_CHECK_RationalModel, mmCalib.iniField, L"RationalModel", mmFile_Paras.iniModelPath());
}
